package com.jereh.music.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.jereh.music.PlayApplication;
import com.jereh.music.constants.Constants;
import com.jereh.music.ible.IMusic;

public class PlayReceiver extends BroadcastReceiver {

    private PlayApplication application;
    private IMusic music;

    @Override
    public void onReceive(Context context, Intent intent) {
        // TODO: This method is called when the BroadcastReceiver is receiving
        application=(PlayApplication)context.getApplicationContext();
        music=application.music;
        String action=intent.getAction();
        switch (action) {
            case "com.jereh.music.play":
                music.moveon();
                break;
            case "com.jereh.music.pause":
                music.pause();
                break;
            case "com.jereh.music.next":
                music.next();
                break;
            case "com.jereh.music.prev":
                music.prev();
                break;
            case "com.jereh.music.cancel":
                //取消状态栏的音乐播放
                application.notiManager.cancel(Constants.PLAY_NOTI);
                break;
        }
    }
}
